package cn.tx.config.rabbitmq;

import cn.tx.constants.HotelMqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: 可乐加糖
 * @create: 2022-12-06 15:35
 * @Description:
 */
@Configuration
public class HoteMqConfig {
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(HotelMqConstants.HOTEL_EXCHANGE_NAME, true, false);
    }

    @Bean
    public Queue insertQueue(){
        return new Queue(HotelMqConstants.HOTEL_INSERT_QUEUE_NAME, true);
    }

    @Bean
    public Queue deleteQueue(){
        return new Queue(HotelMqConstants.HOTEL_DELETE_QUEUE_NAME, true);
    }

    @Bean
    public Binding insertQueueBinding(){
        return BindingBuilder.bind(insertQueue()).to(topicExchange()).with(HotelMqConstants.HOTEL_INSERT_KEY);
    }

    @Bean
    public Binding deleteQueueBinding(){
        return BindingBuilder.bind(deleteQueue()).to(topicExchange()).with(HotelMqConstants.HOTEL_DELETE_KEY);
    }

    @Bean
    public Binding queryQueueBinding(){
        return BindingBuilder.bind(deleteQueue()).to(topicExchange()).with(HotelMqConstants.HOTEL_QUERY_KEY);
    }
}
